<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<link rel="stylesheet"
			href="/resources/plugins/datatables/dataTables.bootstrap.css" />
		<style>
.ui-datatable-scrollable-header-box {
	margin-left: 0px;
	margin-right: 15px !important;
}
</style>
	</ui:define>
	<ui:define name="content">
		<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
			<p:commandButton value="是" type="button"
				styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
			<p:commandButton value="否" type="button"
				styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
		</p:confirmDialog>
		<div id="headDiv" class="box box-solid with-border">
			<h:form id="headForm">
				<p:growl id="msgs" showDetail="true" />
				<div class="box-header" id="queryDiv">
					<p:outputLabel value="电压等级：" style="margin-right:5px" />
					<h:selectOneMenu value="#{stationDistributeController.vol}"
						style="width:100px;height:30px;margin-right:10px">
						<f:selectItem itemLabel="全部" itemValue="" />
						<f:selectItems
							value="#{stationDistributeController.standVoltages}" />
					</h:selectOneMenu>
					<p:autoComplete dropdown="true" placeholder="变电站首字母查询"
						scrollHeight="400"
						value="#{stationDistributeController.stationName}"
						style="margin-right:10px"
						completeMethod="#{stationDistributeController.complateStation}">
					</p:autoComplete>
					<p:commandButton icon="ui-icon-search" value="查询"
						actionListener="#{stationDistributeController.query()}"
						style="margin-left:5px;" update="form:dataTb"
						oncomplete="getTableScrollHeight();" />
				</div>
				<div id="toolbarDiv">
					<p:toolbar id="toolbar">
						<f:facet name="left">
							<p:commandButton id="addBtn" icon="fa fa-plus" value="添加变电站"
								style="margin-right:5px;margin-left:5px"
								onclick="PF('addStationDlg').show()"
								actionListener="#{stationDistributeController.initQueryCondition()}"
								rendered="#{s:hasPermission(session,'gzgl_bdzgl_tjbdz')}"
								update=":addStationForm:stationTb :addStationForm:confirmBtn :addStationForm:vol_text :addStationForm:sName_text"
								oncomplete="getTableScrollHeight();" />
							<p:commandButton id="deleteBtn" value="移除变电站" icon="fa fa-trash"
								style="margin-left:5px;"
								disabled="#{stationDistributeController.selectDistributes.size() == 0}"
								actionListener="#{stationDistributeController.deleteDistributes}"
								rendered="#{s:hasPermission(session,'gzgl_bdzgl_ycbdz')}"
								update="headForm:msgs form:dataTb headForm:deleteBtn"
								oncomplete="getTableScrollHeight();">
								<p:confirm header="提示" message="确定移除吗?" icon="ui-icon-alert" />
							</p:commandButton>
						</f:facet>
					</p:toolbar>
				</div>
			</h:form>
		</div>
		<div id="infoDiv" class="box box-solid with-border">
			<h:form id="form">
				<p:dataTable id="dataTb" var="item" rowKey="#{item.id}"
					emptyMessage="无记录" rowIndexVar="ite"
					value="#{stationDistributeController.distributes}"
					selection="#{stationDistributeController.selectDistributes}"
					lazy="false" rows="20" paginator="true" paginatorPosition="bottom"
					paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="20,50,100" scrollable="true">
					<f:facet name="{Customization}">
						<p:outputLabel style="margin-right:20px"
							value="总计：#{stationDistributeController.distributes.size()}条纪录" />
					</f:facet>
					<p:ajax event="rowSelectCheckbox" process="@all"
						update="headForm:addBtn headForm:deleteBtn" />
					<p:ajax event="rowUnselectCheckbox" process="@all"
						update="headForm:addBtn headForm:deleteBtn" />
					<p:ajax event="rowSelect" process="@all"
						update="headForm:addBtn headForm:deleteBtn" />
					<p:column selectionMode="multiple"
						style="text-align:center;width:60px" />
					<p:column headerText="序号 " style="width:60px;text-align:center">
						<h:outputText value="#{ite+1}" />
					</p:column>
					<p:column headerText="变电站名称" style="text-align:center;width:15%">
						<h:outputText
							value="#{stationDistributeController.getStationLedger(item).name}" />
					</p:column>
					<p:column headerText="调管单位" style="text-align:center;width:20%">
						<h:outputText
							value="#{stationDistributeController.getStationLedger(item).dispatchUnit}" />
					</p:column>
					<p:column headerText="运维单位" style="text-align:center;width:20%">
						<h:outputText
							value="#{stationDistributeController.getStationLedger(item).maintenanceUnit}" />
					</p:column>
					<p:column headerText="电压等级" style="text-align:center;width:10%">
						<h:outputText
							value="#{stationDistributeController.getStation(item).standVoltagelevel}" />
					</p:column>
					<p:column headerText="管理人员" style="text-align:center;width:20%">
						<p:repeat var="dist"
							value="#{stationDistributeController.getStationDistribute(item)}">
							<div style="float: left; width: 80px">
								<h:outputText
									value="#{personAndEquipmentDistributeController.getStationGovernor(dist.personId)}" />
							</div>
						</p:repeat>
					</p:column>
				</p:dataTable>
			</h:form>
			<p:dialog widgetVar="addStationDlg" id="addStationDlg" header="添加变电站"
				modal="true" width="1300" height="790">
				<h:form id="addStationForm" width="1300" height="790">
					<div style="margin-bottom: 10px">
						<p:outputLabel value="电压等级：" style="margin-right:5px" />
						<h:selectOneMenu value="#{stationDistributeController.vol}"
							id="vol_text" style="width:100px;height:30px;margin-right:10px">
							<f:selectItem itemLabel="全部" itemValue="" />
							<f:selectItems
								value="#{stationDistributeController.standVoltages}" />
						</h:selectOneMenu>
						<p:autoComplete dropdown="true" id="sName_text"
							placeholder="变电站首字母查询" scrollHeight="400"
							value="#{stationDistributeController.stationName}"
							style="margin-right:10px"
							completeMethod="#{stationDistributeController.complateStation}">
						</p:autoComplete>
						<p:commandButton icon="ui-icon-search" value="查询"
							actionListener="#{stationDistributeController.queryStation()}"
							style="margin-left:5px;" update="addStationForm:stationTb" />
					</div>
					<p:toolbar>
						<f:facet name="left">
							<p:commandButton id="confirmBtn" value="确定"
								style="margin-right:5px;margin-left:5px"
								disabled="#{stationDistributeController.selectSubStations.size()==0}"
								actionListener="#{stationDistributeController.addStation()}"
								update="addStationForm:stationTb form:dataTb"
								oncomplete="getTableScrollHeight();">
								<p:confirm header="提示" message="确定管理选中的变电站吗?"
									icon="ui-icon-alert" />
							</p:commandButton>
							<p:commandButton value="取消"
								style="margin-right:5px;margin-left:5px"
								onclick="PF('addStationDlg').hide()" />
						</f:facet>
					</p:toolbar>
					<p:dataTable id="stationTb" var="station" rowKey="#{station.id}"
						emptyMessage="无记录" rowIndexVar="ite"
						value="#{stationDistributeController.subStations}"
						selection="#{stationDistributeController.selectSubStations}"
						lazy="false" rows="20" paginator="true" paginatorPosition="bottom"
						paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
						rowsPerPageTemplate="20,50,100">
						<f:facet name="{Customization}">
							<p:outputLabel style="margin-right:20px"
								value="总计：#{stationDistributeController.subStations.size()}条纪录" />
						</f:facet>
						<p:ajax event="rowSelectCheckbox" process="@all"
							update="addStationForm:confirmBtn" />
						<p:ajax event="rowUnselectCheckbox" process="@all"
							update="addStationForm:confirmBtn" />
						<p:ajax event="rowSelect" process="@all"
							update="addStationForm:confirmBtn" />
						<p:column selectionMode="multiple"
							style="text-align:center;width:60px" />
						<p:column headerText="序号 " style="width:60px;text-align:center">
							<h:outputText value="#{ite+1}" />
						</p:column>
						<p:column headerText="变电站名称" style="text-align:center;width:15%">
							<h:outputText value="#{station.name}" />
						</p:column>
						<p:column headerText="调管单位" style="text-align:center;width:15%">
							<h:outputText
								value="#{personAndEquipmentDistributeController.getDispatchUnit(station.id)}" />
						</p:column>
						<p:column headerText="运维单位" style="text-align:center;width:15%">
							<h:outputText
								value="#{personAndEquipmentDistributeController.getMaintenanceUnit(station.id)}" />
						</p:column>
						<p:column headerText="电压等级" style="text-align:center;width:10%">
							<h:outputText value="#{station.standVoltagelevel}" />
						</p:column>
						<p:column headerText="管理人员" style="text-align:center;width:30%">
							<p:repeat var="pd"
								value="#{personAndEquipmentDistributeController.getStationDistribute(station)}">
								<div style="float: left; width: 80px">
									<h:outputText
										value="#{personAndEquipmentDistributeController.getStationGovernor(pd.personId)}" />
								</div>
							</p:repeat>
						</p:column>
					</p:dataTable>
				</h:form>
			</p:dialog>
		</div>
	</ui:define>
	<ui:define name="contentend">
		<script src="/resources/js/tables/singleScrollTable.js" />
	</ui:define>
</ui:composition>